/* 
 * File:   map.cpp
 * Author: phuongdong
 *
 * Created on April 16, 2013, 11:10 AM
 */

#include <cstdlib>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;

/*
 * 
 */

void example1(){ // how to use begin
    std::map<char,int> mymap;
    std::map<char,int>::iterator it;

    mymap['b'] = 100;
    mymap['a'] = 200;
    mymap['c'] = 300;

    // show content:
    for (it=mymap.begin(); it!=mymap.end(); ++it)
    std::cout << it->first << " => " << it->second << '\n';
}

void example2(){//how to use clear
    std::map<char,int> mymap;

    mymap['x']=100;
    mymap['y']=200;
    mymap['z']=300;

    std::cout << "mymap contains:\n";
    for (std::map<char,int>::iterator it=mymap.begin(); it!=mymap.end(); ++it)
    std::cout << it->first << " => " << it->second << '\n';

    mymap.clear();
    mymap['a']=1101;
    mymap['b']=2202;

    std::cout << "mymap contains:\n";
    for (std::map<char,int>::iterator it=mymap.begin(); it!=mymap.end(); ++it)
    std::cout << it->first << " => " << it->second << '\n';
}

void example3(){//how to use count
    
    std::map<char,int> mymap;
    char c;

    mymap ['a']=101;
    mymap ['c']=202;
    mymap ['f']=303;

    for (c='a'; c<'h'; c++)
    {
        std::cout << c;
        if (mymap.count(c)>0)
          std::cout << " is an element of mymap.\n";
        else 
          std::cout << " is not an element of mymap.\n";
    }
}

void codejam(){
    FILE * file = fopen("1.in","r");
    FILE * fileO = fopen("1.txt","r+w");
    
    ofstream outfile("1.txt");

    char ori[] =     "ejp mysljylc kd kxveddknmc re jsicpdrysi rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd de kr kd eoya kw aej tysr re ujdr lkgc jv";
    char convert[] = "our language is impossible to understand there are twenty six factorial possibilities so it is okay if you want to just give up";
    
    map<char,char> mymap;
    for(int i=0;i< sizeof(ori)-1;i++){
        mymap[ori[i]]=convert[i];
    }
    
    char sInput[100];
    
    ifstream infile("1.in");
    int numTest;
    fscanf(file,"%d",&numTest);
    //int numTest = atoi(line.c_str());
    for(int i=0;i<numTest;i++){
        //getline(infile,line);
        fscanf(file,"%s",sInput);
        for(int j=0;sInput[j];j++){
            outfile <<sInput[j];
        }
        outfile << endl;
    }
    fclose(file);
    fclose(fileO);
}
char map1(char x){
    switch (x){
        case ' ':
            return ' ';
           
        case 'a':
            return 'y';
        case 'b':
            return 'h';
        case 'c':
            return 'e';
        case 'd':
            return 's';
        case 'e':
            return 'o';
        case 'f':
            return 'c';
        case 'g':
            return 'v';
           
        case 'h':
            return 'x';
        case 'i':
            return 'd';
        case 'j':
            return 'u';
        case 'k':
            return 'i';
        case 'l':
            return 'g';
        case 'm':
            return 'l';
        case 'n':
            return 'b';
        case 'o':
            return 'k';
        case 'p':
            return 'r';
        case 'q':
            return 'z';
        case 's':
            return 'n';
        case 't':
            return 'w';
        case 'u':
            return 'j';
        case 'v':
            return 'p';
        case 'x':
            return 'm';
        case 'y':
            return 'a';
        case 'z':
            return 'q';
        case 'r':
            return 't';
        case 'w':
            return 'f';
    }
}
void codejam2(){
    FILE * file = fopen("1.in","r");
    FILE * fileO = fopen("1.out","w");
   
    ifstream infile("1.in");
   
    string line;
    getline(infile,line);
    int numTest = atoi(line.c_str());
    for(int i=0;i<numTest;i++){
        getline(infile,line);
        fprintf(fileO,"Case #%d: ",i+1);
        for(int j=0;j<line.length();j++){
            char result = map1(line.at(j));
            fprintf(fileO,"%c",result);
        }
        fprintf(fileO,"\n");
    }
}

int main(int argc, char** argv) {
    codejam();
    return 0;
}

